package com.rain.cy.business.service;

import com.rain.cy.business.model.entity.CommonProcessEntity;
import com.rain.cy.business.mapper.CommonProcessMapper;
import com.rain.cy.framework.entity.impl.BaseServiceImpl;
import org.springframework.stereotype.Service;

import java.util.Map;
import java.util.stream.Collectors;

/**
 * <p>
 * 流程定义表 服务实现类
 * </p>
 *
 * @author yuchen
 * @since 2021-10-02
 */
@Service
public class CommonProcessService extends BaseServiceImpl<CommonProcessMapper, CommonProcessEntity> {


    public Map<Integer, String> getProcessMap() {
        return lambdaQuery().list().stream()
                .filter(commonProcessEntity -> "0".equals(commonProcessEntity.getParentId()))
                .collect(Collectors.toMap(
                        commonProcessEntity -> Integer.parseInt(commonProcessEntity.getId()) / 10,
                        CommonProcessEntity::getProcessName
                ));
    }
}
